// MainDlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once
#include "Working.h"
class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>,
		public CDialogResize<CMainDlg>,
		public CMessageFilter, public CIdleHandler, 
		public LogReceiver, public StateMangr
{
public:
	enum { IDD = IDD_MAINDLG };
	CMainDlg();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL OnIdle();

	BEGIN_UPDATE_UI_MAP(CMainDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_CLOSE, OnClose)
		COMMAND_ID_HANDLER(IDC_BTN_BEGIN, OnBtnBegin)
		COMMAND_ID_HANDLER(IDC_BTN_BEGIN, OnBtnSelFile)
		CHAIN_MSG_MAP(CDialogResize<CMainDlg>)
		ALT_MSG_MAP(1)
			MESSAGE_HANDLER(WM_DROPFILES,OnDropFiles)
	END_MSG_MAP()

	BEGIN_DLGRESIZE_MAP(CMainDlg)
		DLGRESIZE_CONTROL(IDC_EDIT_CFGPATH,DLSZ_SIZE_X)
		DLGRESIZE_CONTROL(IDC_BTN_OPEN,DLSZ_MOVE_X)
		DLGRESIZE_CONTROL(IDC_RICHEDIT,DLSZ_SIZE_X|DLSZ_SIZE_Y)
		BEGIN_DLGRESIZE_GROUP()
			DLGRESIZE_CONTROL(IDC_BTN_BEGIN,DLSZ_MOVE_Y|DLSZ_SIZE_X)
			DLGRESIZE_CONTROL(IDC_BTN_CLOSE,DLSZ_MOVE_Y|DLSZ_SIZE_X)
		END_DLGRESIZE_GROUP()
	END_DLGRESIZE_MAP()
// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnDropFiles(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBtnBegin(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnBtnSelFile(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	void CloseDialog(int nVal);
	
public:
	virtual void Log(LPCTSTR lpLogStr, int nFormat = CLR_NROMAL|FONT_NORMAL);
	virtual void SetState(BOOL bEnable);
private:
	CWorking* m_pWorking;
	CContainedWindowT<CEdit> m_editPath;
	CRichEditCtrl m_richEdit;
};
